<?php

namespace App\Http\Requests\Api;

use App\Exceptions\ResponseException;
use Illuminate\Foundation\Http\FormRequest;

/**
 * 基础验证器类
 * @package App\Http\Requests\Api
 */
class BaseRequest extends FormRequest
{
    public function authorize()
    {
        return true;
    }

	/**
	 * 重新验证失败的方法，让其返回json的错误信息
	 * User: ihome
	 * @param \Illuminate\Contracts\Validation\Validator $validator
	 */
	public function failedValidation($validator)
    {
		$message = $validator->errors()->first();

		throw new ResponseException(400,$message);
    }

}
